/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frmwrk.core;

import frmwrk.interfaces.IAccount;
import frmwrk.interfaces.IEntry;
import frmwrk.interfaces.IParty;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;

/**
 *
 * @author Damian
 */
public class Account extends Observable implements IAccount {

    protected String accountType;
    int accountNumber;
    Double balance;
    IParty party;
    List<IEntry> entryList;

    public Account(int accountNumber, Double balance) {
        this.accountNumber = accountNumber;
        this.balance = balance;
        this.party = party;
        this.entryList = new ArrayList<IEntry>();
    }

    public void setParty(IParty party) {
        this.party = party;
    }

    public IParty getParty() {
        return party;
    }

    @Override
    public String getAccountType() {
        return accountType;
    }

    @Override
    public int getAccountNumber() {
        return accountNumber;
    }

    @Override
    public void setAccountNumber(int accountNumber) {
        this.accountNumber = accountNumber;
    }

    @Override
    public Double getBalance() {
        return balance;
    }

    @Override
    public void setBalance(Double balance) {
        this.balance = balance;
    }

    @Override
    public boolean addEntry(IEntry entry) {
        boolean result = false;
        if (entry.execute()) {
            result = true;
            this.entryList.add(entry);
        }
        setChanged();
        notifyObservers(entry);
        return result;    
    }
}
